//
//  NSObject+PrintIvars.swift
//  表情键盘
//
//  Created by liyonggui on 16/5/24.
//  Copyright © 2016年 liyonggui. All rights reserved.
//

import Foundation

extension NSObject {
    /// runtime打印所有属性
    class func printIvars(){
        var outCount: UInt32 = 0
        let ivars = class_copyIvarList(self, &outCount)
        for var i: UInt32 = 0; i < outCount; i++ {
            let ivar = ivars[Int(i)]
            let cName = ivar_getName(ivar)
            let name = String(CString: cName, encoding: NSUTF8StringEncoding)
            print("name: \(name)")
            
            let cType = ivar_getTypeEncoding(ivar)
            let type = String(CString: cType, encoding: NSUTF8StringEncoding)
            print("type: \(type)")
        }
        
    }
}
